*Dataset to be used
use "F:\WSCEP\Governance Paper with PB data\differences margins_month.dta" 


***use these commands in case labels need to be defined***
***if labels already defined, start with commands below Pension over time***


lab def pro 0 "Pensions" 1 "Unemployment benefits"
lab val programme pro 

lab def dr 0 "Defector" 1 "Rewarder"
lab val def_rew dr 

lab def dir 0 "Expansion" 1 "Cut"
lab val direction dir

lab def sig 0 "no sig. diff." 1 "Sig. diff."
lab val significance sig


**********************Pension over time***********************************

*********color***************
*marginal effects of pensions expansions over months
twoway rarea lb ub month if programme==0&def_rew==0&dir==0, color (orange_red) ///
|| 	   rarea lb ub month if programme==0&def_rew==1&dir==0, color(midblue) lpattern(solid) ///
||     line margin month if programme==0&def_rew==0&dir==0, lcolor(cranberry) lpattern(solid)  ///
|| 	   line margin month if programme==0&def_rew==1&dir==0, lcolor(blue) lpattern(solid) ///
ytitle("Marginal effect of expansion", axis(1) size(medium) height(5)) ///
xtitle("Number of months after expansion", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("pens_exp_time", replace)


*marginal effects of pensions cutbacks over months
twoway rarea lb ub month if programme==0&def_rew==0&dir==1, color (orange_red) ///
|| 	   rarea lb ub month if programme==0&def_rew==1&dir==1, color(midblue) lpattern(solid) ///
||     line margin month if programme==0&def_rew==0&dir==1, lcolor(cranberry) lpattern(solid)  ///
|| 	   line margin month if programme==0&def_rew==1&dir==1, lcolor(blue) lpattern(solid) ///
ytitle("Marginal effect of cutback", axis(1) size(medium) height(5)) ///
xtitle("Number of months after cutback", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("pens_cut_time", replace)


*********bw***************
*marginal effects of pensions expansions over months
twoway rarea lb ub month if programme==0&def_rew==0&dir==0, color (gs4) ///
|| 	   rarea lb ub month if programme==0&def_rew==1&dir==0, color(gs12) lpattern(solid) ///
||     line margin month if programme==0&def_rew==0&dir==0, lcolor(black) lpattern(solid)  ///
|| 	   line margin month if programme==0&def_rew==1&dir==0, lcolor(gs8) lpattern(dash) ///
ytitle("Marginal effect of expansion", axis(1) size(medium) height(5)) ///
xtitle("Number of months after expansion", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("pens_exp_time_bw", replace)


*marginal effects of pensions cutbacks over months
twoway rarea lb ub month if programme==0&def_rew==0&dir==1, color (gs4) ///
|| 	   rarea lb ub month if programme==0&def_rew==1&dir==1, color(gs12) lpattern(solid) ///
||     line margin month if programme==0&def_rew==0&dir==1, lcolor(black) lpattern(solid)  ///
|| 	   line margin month if programme==0&def_rew==1&dir==1, lcolor(gs8) lpattern(dash) ///
ytitle("Marginal effect of cutback", axis(1) size(medium) height(5)) ///
xtitle("Number of months after cutback", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("pens_cut_time_bw", replace)


grc1leg pens_exp_time pens_cut_time, colfirst commonscheme scale(1) ycommon ///
graphregion(color(white))

grc1leg pens_exp_time_bw pens_cut_time_bw, colfirst commonscheme scale(1) ycommon ///
graphregion(color(white)) title("Pensions", size(medium) color(black)) ///
name("pensions_time_bw", replace)



**********************UB over time***********************************

*********color***************
*marginal effects of ub expansions over months
twoway rarea lb ub month if programme==1&def_rew==0&dir==0, color (orange_red) ///
|| 	   rarea lb ub month if programme==1&def_rew==1&dir==0, color(midblue) lpattern(solid) ///
||     line margin month if programme==1&def_rew==0&dir==0, lcolor(cranberry) lpattern(solid)  ///
|| 	   line margin month if programme==1&def_rew==1&dir==0, lcolor(blue) lpattern(solid) ///
ytitle("Marginal effect of expansion", axis(1) size(medium) height(5)) ///
xtitle("Number of months after expansion", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("ub_exp_time", replace)


*marginal effects of ub cutbacks over months
twoway rarea lb ub month if programme==1&def_rew==0&dir==1, color (orange_red) ///
|| 	   rarea lb ub month if programme==1&def_rew==1&dir==1, color(midblue) lpattern(solid) ///
||     line margin month if programme==1&def_rew==0&dir==1, lcolor(cranberry) lpattern(solid)  ///
|| 	   line margin month if programme==1&def_rew==1&dir==1, lcolor(blue) lpattern(solid) ///
ytitle("Marginal effect of cutback", axis(1) size(medium) height(5)) ///
xtitle("Number of months after cutback", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("ub_cut_time", replace)


*********bw***************
*marginal effects of ub expansions over months
twoway rarea lb ub month if programme==1&def_rew==0&dir==0, color (gs4) ///
|| 	   rarea lb ub month if programme==1&def_rew==1&dir==0, color(gs12) lpattern(solid) ///
||     line margin month if programme==1&def_rew==0&dir==0, lcolor(black) lpattern(solid)  ///
|| 	   line margin month if programme==1&def_rew==1&dir==0, lcolor(gs8) lpattern(dash) ///
ytitle("Marginal effect of expansion", axis(1) size(medium) height(5)) ///
xtitle("Number of months after expansion", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("ub_exp_time_bw", replace)


*marginal effects of ub cutbacks over months
twoway rarea lb ub month if programme==1&def_rew==0&dir==1, color (gs4) ///
|| 	   rarea lb ub month if programme==1&def_rew==1&dir==1, color(gs12) lpattern(solid) ///
||     line margin month if programme==1&def_rew==0&dir==1, lcolor(black) lpattern(solid)  ///
|| 	   line margin month if programme==1&def_rew==1&dir==1, lcolor(gs8) lpattern(dash) ///
ytitle("Marginal effect of cutback", axis(1) size(medium) height(5)) ///
xtitle("Number of months after cutback", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
yline(.00, lcolor(black)) ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6", angle (0) labsize(medium)) ///
legend(order(3 "Defectors" 4 "Rewarders")) ///
title("", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("ub_cut_time_bw", replace)


grc1leg ub_exp_time ub_cut_time, colfirst commonscheme scale(1) ycommon ///
graphregion(color(white))

grc1leg ub_exp_time_bw ub_cut_time_bw, colfirst commonscheme scale(1) ycommon ///
graphregion(color(white)) title("Unemployment insurance", size(medium) color(black)) ///
name("ub_time_bw", replace)


*Common Figure for both schemes
grc1leg pensions_time_bw ub_time_bw, colfirst commonscheme scale(0.9) cols(1) ycommon ///
graphregion(color(white))

graph display, xsize(5.5) ysize(6.5) 


graph save Graph "F:\WSCEP\Governance Paper with PB data\Figure 3 marginal effects with time lags.gph", replace
graph save Graph "F:\WSCEP\Governance Paper with PB data\Final Version Governance\Figure 3.gph", replace
graph export "F:\WSCEP\Governance Paper with PB data\Final Version Governance\Figure 3.tif", replace width(1200)
